<script>
import { api } from '@/api';
import { useAppStore } from '@/stores/app';
import { mapStores } from 'pinia';
import { Cell, List } from 'vant';

export default {
  components: {
    List,
    Cell
  },
  computed: {
    ...mapStores(useAppStore)
  },
  data() {
    return {
      list: [],
      loading: false,
      finished: false
    }
  },
  created() {
    // this.handleLoad()
  },
  methods: {
    async handleLoad() {
      const { data } = await api.account.inviteList({ invitation_code: this.appStore.userInfo.invitationCode })
      this.finished = true
      this.loading = false
      if (!data) return
      this.list.push(...data)
    },
  },
}
</script>

<template>
  <div class="invite-record">
    <List v-model="loading" :finished="finished" finished-text="没有更多了" @load="handleLoad">
      <Cell v-for="item in list" :key="item.id" :title="item.user_name" :value="item.create_time" />
    </List>
  </div>
</template>

<style lang="less" scoped>
.invite-record {
  height: 100%;
}
</style>
